package dao

import (
	"express/global"
	"express/internal/model"
)

func GetUserByPhone(phone string) (*model.User, error) {
	u := &model.User{}
	err := global.DBEngine.Where("phone = ?", phone).First(u).Error
	return u, err
}

func CreateUser(phone string, nickname string, passHash string, identifier int64) error {
	user := model.User{
		Phone:      phone,
		Nickname:   nickname,
		Identifier: identifier,
		Password:   passHash,
		IsLogin:    false,
	}
	err := global.DBEngine.Create(&user).Error
	return err
}
